// 经此一役小红所向无敌(模拟)
#include <iostream>
using namespace std;

using ll = long long;

int main()
{
    ll a, h, b, k;
    cin >> a >> h >> b >> k;
    ll res = 0;
    int cnt = min(h / b, k / a);
    res += (a + b) * cnt;
    h -= cnt * b;
    k -= cnt * a;
    if (h > 0 && k > 0)
    {
        res += a + b;
        // 这次减完后必然至少有一方死亡
        h -= b;
        k -= a;
    }
    if (h > 0 || k > 0)
        res += 10 * (h > 0 ? a : b);
    cout << res << endl;
    return 0;
}

// 连续子数组最大和(动态规划)
#include <iostream>
using namespace std;

const int N = 2e5 + 10;
int dp[N];
int res = -0x3f3f3f3f;

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) 
    {
        int x; cin >> x;
        dp[i] = max(dp[i - 1], 0) + x;
        res = max(res, dp[i]);
    }
    cout << res << endl;
    return 0;
}

// 非对称之美(贪心)
#include <iostream>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int l = 0, r = n - 1;
    while (s[l] == s[r]) l++, r--;
    if (l >= r) // 是回文串
    {
        // 判断所有字符是否都相同
        int flag = 1;
        for (auto ch : s)
        {
            if (s[0] != ch)
            {
                flag = 0;
                break;
            }
        }
        if (flag) cout << 0 << endl;
        else cout << n - 1 << endl;
    }
    else cout << n << endl;
    return 0;
}
